<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('组织信息')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<form id="user-form">
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <!-- 公司搜索栏 -->
                <div class="col-sm-12 search-collapse" id="compCondition">
                    <div class="select-list">
                        <ul>
                            <li>
                                公司编码：<input type="text" name="compCode" id="compCode"/>
                            </li>
                            <li>
                                集团名称：<select name="compGroup" id="compGroup"
                                             th:with="type=${@dict.getType('OCD_COMPGROUP2')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                公司名称：<input type="text" id="title" name="title"/>
                            </li>
                            <li>
                                公司级别：<select name="compGrade" id="compGrade"
                                             th:with="type=${@dict.getType('oCD_CompGrade')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                上级公司：<input type="text" id="adminName" name="adminName"/>
                            </li>
                            <li>
                                <button type="button" onclick="$.table.search()" class="btn btn-primary btn-sm"><i
                                        class="fa fa-search"></i>&nbsp;搜索
                                </button>
                                <button type="button" onclick="$.form.reset()" class="btn btn-warning btn-sm"><i
                                        class="fa fa-refresh"></i>&nbsp;重置
                                </button>
                                <button type="button" onclick="$.table.exportExcel()" class="btn btn-danger btn-sm"><i
                                        class="fa fa-download"></i>&nbsp;导出
                                </button>
                            </li>
                        </ul>
                    </div>
                </div>


                <!-- 公司表格DIV -->
                <div class="col-sm-12 select-table table-striped" id="comp">
                    <table id="bootstrap-table" data-mobile-responsive="true"></table>
                </div>

            </div>
        </div>
    </div>
</form>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">
    var prefix = ctx + "company";

    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryCompanyList();
    });

    //加载公司表格
    function queryCompanyList() {
        var options = {
            code: "compID",
            uniqueId: "compID",
            url: ctx + "company/info/list?isDisabled=1",
            exportUrl:  ctx + "company/info/export",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "公司",
            columns: [{
                checkbox: true
            }, {
                field: 'compCode',
                title: '公司编号',
            },
                {
                    field: 'compGroupName',
                    title: '集团名称'
                },
                {
                    field: 'title',
                    title: '公司名称',
                    width: '200',
                    sortable: true
                },
                {
                    field: 'compAbbr',
                    title: '公司简称'
                },
                {
                    field: 'compGradeName',
                    title: '公司级别'
                },
                {
                    field: 'compTypeName',
                    title: '公司类型'
                },
                {
                    field: 'industuName',
                    title: '所属行业'
                },
                {
                    field: 'compAreaName',
                    title: '公司区域'
                },
                {
                    field: 'adminName',
                    title: '上级公司'
                },
                {
                    field: 'lawyer',
                    title: '法人代表'
                },
                {
                    field: 'address',
                    title: '公司地址'
                },
                {
                    field: 'regAddress',
                    title: '注册地址'
                },
                {
                    field: 'tel',
                    title: '联系电话'
                },
                {
                    field: 'postCode',
                    title: '邮政编码'
                },
                {
                    field: 'webSite',
                    title: '公司网站'
                },
                {
                    field: 'socialcreCode',
                    title: '统一社会信用代码'
                },
                {
                    field: 'enterpriseQuafic',
                    title: '企业资质'
                },
                {
                    field: 'companyprofile',
                    title: '公司简介'
                },
                {
                    field: 'effectDate',
                    title: '成立日期'
                }]
        };
        $.table.init(options);
    }


    //刷新公司表格
    function compRefresh() {
        $("#comp-table").bootstrapTable('refresh');
    }


    //导出公司信息
    function compExport() {
        var compCode = $("#compCode").val();
        var compGroup = $("#compGroup").val();
        var title = $("#title").val();
        var compGrade = $("#compGrade").val();
        var adminName = $("#adminName").val();

        $.ajax({
            cache: true,
            type: "POST",
            url: "/company/export",
            data: {
                "compCode": compCode,
                "compGroup": compGroup,
                "title": title,
                "compGrade": compGrade,
                "adminName": adminName
            },
            success: function (request) {
                window.location.href = ctx + "common/download?fileName=" + request.msg + "&delete=" + true;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }
</script>


</body>
</html>